/**
 * Copyright 厦门中软海晟信息技术有限公司 版权所有 违者必究 2019
 */
package com.math;

import java.util.ArrayList;
import java.util.List;

/**
 * @author : sunzb(sunzb@hsit.com.cn)
 * @date: 2019/5/9
 */
public class Lesson8_1_q {

    public static List<List<Integer>> test() {
        List<List<Integer>> result = new ArrayList<>();
        ArrayList<Integer> rest = new ArrayList<>();
        for (int i = 1; i <= 20; i++) {
            rest.add(i);
        }
        dg(rest, result, new ArrayList<>());
        return result;
    }

    public static void dg(ArrayList<Integer> rest, List<List<Integer>> result, ArrayList<Integer> store) {
        if (store.size() == 14) {
            result.add(store);
            return;
        }
        for (int i = 0; i < rest.size(); i++) {
            ArrayList<Integer> newRest = (ArrayList<Integer>) rest.clone();
            ArrayList<Integer> newStore = (ArrayList<Integer>) store.clone();
            Integer value = rest.get(i);
            newRest.remove(value);
            newStore.add(value);
            dg(newRest, result, newStore);
        }
    }

    public static void main(String[] args) {
        System.out.println(test());
    }
}
